package com.hansming.bss.modules.sfc.entity;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Random;

import org.apache.commons.lang3.RandomUtils;

import com.hansming.bss.common.persistence.DataEntity;

/**
 * 订单Entity
 * @author Hansming
 * @version 2017-09-16
 */
public class Order extends DataEntity<Order> {

	private static final long serialVersionUID = 1L;
	
	private				String 				num;						//订单编号		
	private 			BigDecimal 			price;					//价格	
	private				String 				state;					//状态	
	private 			String 				type;						//订单类别（1，租车订单 2，租车旅游订单）	
	private 			Contacts 			contacts;				//联系人	
	private 			int 				score_costs;			//消耗积分		
	private 			CarInfo 			carinfo;					//房车信息
	private 			Customer 			customer;				//关联用户
	private				String 				pricedetail;			//订单细节
	private 			Line 				line;						//线路信息
    private 			String 				beginDate;			// 开始时间
    private 			String 				endDate;				// 结束时间
    private 			String 				cus_msg;				// 客户留言
    private				List<Traveller>	travellers;				//线路游客信息集合（租车无需游客的信息，线路需要游客的信息，该属性只在线路的订单中使用）
    private 			String 				cname;					//订单固定的联系人信息
    private				String				identtype;				//联系人身份证件类型	**此类型只为租车中用得到
    private				String				identnum;				//联系人证件号码
    private				String				phone;					//电话
    private				String				email;					//邮箱	
    private 			String 				productname;		//商品名称
    private				String				prepayid;				//支付用prepayid
    private    			int 					wxnum; 				//给微信的订单号
    private				int					begintime;			//起始时间
    private				int					endtime;				//结束时间
    private				String				cusmsg;				//用户留言
    private				int					adult;					//线路成年人数量
    private				int					child;					//线路未成年人数量
    private				String				branchname;		//分支名称
    
    
    public static int[] nums = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    public static Random random = new Random();
    
    
    
    
    
    
    public String getPrepayid() {
		return prepayid;
	}

	public void setPrepayid(String prepayid) {
		this.prepayid = prepayid;
	}

	public Order(){
    	
    	
	}
    
	public void setOrderNum(){
		SimpleDateFormat dft = new SimpleDateFormat("yyyyMMdd");
    	Date date = new Date();
    	String nums = randomNumber(5);
    	this.num=dft.format(date)+nums;
	}
	
	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}


	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public int getScore_costs() {
		return score_costs;
	}

	public void setScore_costs(int score_costs) {
		this.score_costs = score_costs;
	}


	public String getNum() {
		return num;
	}

	public void setNum(String num) {
		this.num = num;
	}

	public Contacts getContacts() {
		return contacts;
	}

	public void setContacts(Contacts contacts) {
		this.contacts = contacts;
	}

	public CarInfo getCarinfo() {
		return carinfo;
	}

	public void setCarinfo(CarInfo carinfo) {
		this.carinfo = carinfo;
	}

	public Line getLine() {
		return line;
	}

	public void setLine(Line line) {
		this.line = line;
	}


	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(String beginDate) {
		this.beginDate = beginDate;
	}

	public String getEndDate() {
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

	public String getCus_msg(){
		return cus_msg;
	}

	public void setCus_msg(String cus_msg) {
		this.cus_msg = cus_msg;
	}

	public String getPricedetail() {
		return pricedetail;
	}

	public void setPricedetail(String pricedetail) {
		this.pricedetail = pricedetail;
	}

	public List<Traveller> getTravellers() {
		return travellers;
	}

	public void setTravellers(List<Traveller> travellers) {
		this.travellers = travellers;
	}

	public String getCname() {
		return cname;
	}

	public void setCname(String cname) {
		this.cname = cname;
	}

	public String getIdenttype() {
		return identtype;
	}

	public void setIdenttype(String identtype) {
		this.identtype = identtype;
	}

	public String getIdentnum() {
		return identnum;
	}

	public void setIdentnum(String identnum) {
		this.identnum = identnum;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	
	public static String randomNumber(int length) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int index = random.nextInt(10);
            builder.append(nums[index]);
        }
        return builder.toString();
    }

	public String getProductname() {
		return productname;
	}




	public void setProductname(String productname) {
		this.productname = productname;
	}

	public int getWxnum() {
		return wxnum;
	}

	public void setWxnum(int wxnum) {
		this.wxnum = wxnum;
	}
	




	public int getBegintime() {
		return begintime;
	}

	public void setBegintime(int begintime) {
		this.begintime = begintime;
	}

	public int getEndtime() {
		return endtime;
	}

	public void setEndtime(int endtime) {
		this.endtime = endtime;
	}







	public String getCusmsg() {
		return cusmsg;
	}

	public void setCusmsg(String cusmsg) {
		this.cusmsg = cusmsg;
	}

	public String getBranchname() {
		return branchname;
	}

	public void setBranchname(String branchname) {
		this.branchname = branchname;
	}

	public int getAdult() {
		return adult;
	}

	public void setAdult(int adult) {
		this.adult = adult;
	}

	public int getChild() {
		return child;
	}

	public void setChild(int child) {
		this.child = child;
	}







	//订单TYPE
	public static final String TYPE_CAR = "1";				//type = 1 为租车订单
	public static final String TYPE_LINE = "2";				//TYPE = 2 为线路订单
    
	//订单状态
	public static final String STATE_PAYING = "1";			//待支付
	public static final String STATE_COMFIRMMING = "2";		//确认中
	public static final String STATE_RESERVE = "3";			//预定成功
	public static final String STATE_TRAVELLING = "4";		//出行中
	public static final String STATE_EVALUATE	=	"5"	;	//待评价	
	public static final String STATE_CANCEL	=	"6";		//已取消	
	public static final String STATE_REFUND = "7";			//退款中	
	public static final String STATE_HAVEDREFUND = "8";		//退款成功	
			
	
	
}
